package com.zyy.smartcity1129.zhdj;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.zyy.smartcity1129.BaseFragment;
import com.zyy.smartcity1129.R;
import com.zyy.smartcity1129.home.HomeFragment;

/**
 * @ClassName: DJFeedbackFragment$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 13/12/2021$
 * @Version: 1.0
 */
public class DJFeedbackFragment extends BaseFragment {
    private EditText editContext;
    private EditText editTitle;
    private Button btnSubmit;
    public static DJFeedback1Fragment.messageInfo myInfo;

    @Override
    protected int layId() {
        return R.layout.f_zhdj_feedback;
    }

    @Override
    protected String title() {
        right.setVisibility(View.VISIBLE);
        right.setText("查看留言");
        return "建言献策";
    }

    @Override
    protected boolean back() {
        return true;
    }

    @Override
    protected Boolean bottom() {
        return null;
    }

    @Override
    protected void init(View iv) {
        initView(iv);
        btnSubmit.setOnClickListener(view -> {
            String context = editContext.getText().toString().trim();
            String title = editTitle.getText().toString().trim();
            if (!context.equals("") && !title.equals("")) {
                myInfo = new DJFeedback1Fragment.messageInfo(HomeFragment.userBeans.getNickName(), title, context);
                editContext.setText("");
                editTitle.setText("");
                add(new DJFeedback1Fragment());
            } else {
                Toast.makeText(getContext(), "内容不能为空", Toast.LENGTH_SHORT).show();
            }
        });
        right.setOnClickListener(view -> {
            add(new DJFeedback1Fragment());
        });
    }

    private void initView(View iv) {
        editContext = (EditText) iv.findViewById(R.id.editContext);
        editTitle = (EditText) iv.findViewById(R.id.editTitle);
        btnSubmit = (Button) iv.findViewById(R.id.btnSubmit);
    }
}
